using System;
using System.Collections.Generic;
using System.Text;
using System.Collections;

namespace GameEditor.Common
{
    public class ComparerDelegates<T> : IComparer<T>, IComparer
    {

        Comparison<T> comparison;
        public Comparison<T> Comparison
        {
            get { return comparison; }
        }
        public ComparerDelegates(Comparison<T> comparison)
        {
            this.comparison = comparison;
        }


        int IComparer<T>.Compare(T x, T y)
        {
            return comparison(x, y);
        }


        public int Compare(object x, object y)
        {
            return comparison((T)x, (T)y);
        }
         
        public static System.Comparison<T> GetComparison(IComparer<T> comparer)
        {
            return new System.Comparison<T>(
                delegate(T x, T y)
                {
                    return comparer.Compare(x, y);
                });
        }
    }
}
